package com.xinjian.jianba.exception;

import java.io.Serializable;

public class PageParameter implements Serializable {

	private static final long serialVersionUID = -7132908041525377111L;

	private static final Integer DEFAULT_PAGE_SIZE = 20;

	private static final Integer DEFAULT_PAGE_NUMBER = 1;

	private Integer pageNumber = DEFAULT_PAGE_NUMBER;

	private Integer pageSize = DEFAULT_PAGE_SIZE;

	private Integer offset;

	public Integer getPageNumber() {
		return pageNumber;
	}

	/**
	 * 设置页码.
	 *
	 * @param pageNumber
	 */
	public void setPageNumber(Integer pageNumber) {
		if (pageNumber == null || pageNumber < 1) {
			pageNumber = 1;
		}
		this.pageNumber = pageNumber;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	/**
	 * 偏移量，第几条记录.
	 *
	 * @return
	 */
	public Integer getOffset() {
		this.offset = (this.pageNumber - 1) * this.pageSize;
		return offset;
	}

}
